import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import DataVVue3Plugin from '@kjgl77/datav-vue3'
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
import axios from 'axios'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import naive from 'naive-ui'
import { createPinia } from 'pinia'

// 设置 rem 基准值
function setRem() {
  const baseWidth = 2560
  const scale = document.documentElement.clientWidth / baseWidth
  document.documentElement.style.fontSize = `${256 * scale}px`
}

// 初始化
setRem()
// 改变窗口大小时重新设置 rem
window.addEventListener('resize', setRem)

const vuetify = createVuetify({
  components,
  directives,
})

const app = createApp(App)

axios.defaults.baseURL = 'http://192.168.1.100:8080'

app.use(router)
app.use(DataVVue3Plugin)
app.use(vuetify)
app.use(naive)
app.use(createPinia())

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.mount('#app')
